package com.eclink.asset.consume.controller;

import com.eclink.asset.consume.domain.dao.ConsumeAuditConfig;
import com.eclink.asset.consume.service.ConsumeAuditConfigService;
import com.eclink.asset.pojo.query.AssetAuditConfigQuery;
import com.ruoyi.common.core.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 资产审批配置接口Controller
 *
 * @author chenshixian
 * @date 2024-08-24
 */
@Api("耗材审批配置接口列表")
@RestController
@RequestMapping("/consume/assetAuditConfig")
public class ConsumeAuditConfigController extends BaseController {

    @Resource
    private ConsumeAuditConfigService service;

    @ApiOperation("查询")
    @PostMapping("/list")
    public ResponseEntity<Page<ConsumeAuditConfig>> list(@RequestBody AssetAuditConfigQuery query, Pageable page) {
        List<ConsumeAuditConfig> list = service.selectList(query, page);
        return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
    }

    @ApiOperation("详细信息")
    @GetMapping(value = "/{id}")
    public ResponseEntity<ConsumeAuditConfig> getInfo(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(service.selectById(id));
    }

    @ApiOperation("新增")
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody ConsumeAuditConfig assetAuditConfig) {
        return ResponseEntity.ok(service.insert(assetAuditConfig));
    }

    @ApiOperation("修改")
    @PutMapping
    public ResponseEntity<Integer> edit(@RequestBody ConsumeAuditConfig assetAuditConfig) {
        return ResponseEntity.ok(service.update(assetAuditConfig));
    }

    @ApiOperation("删除")
	@DeleteMapping("/{ids}")
    public ResponseEntity<Integer> remove(@PathVariable Long[] ids) {
        return ResponseEntity.ok(service.deleteByIds(ids));
    }
}
